import { 
	_decorator, 
	Component, 
	Vec3, 
	view 
} from 'cc';
const { ccclass, property } = _decorator;

const MOVESPEED = 30;

@ccclass('Background')
export class Background extends Component {
    start() {

    }

    update(deltaTime: number) {
		this.node.position = this.node.position.add(
		  new Vec3(0, -MOVESPEED * deltaTime, 0)
		);
		if (this.node.position.y <= -view.getVisibleSize().height) {
		  let offsetY = this.node.position.y + view.getVisibleSize().height;
		  // let offsetY = -2 * view.getVisibleSize().height;
		  this.node.position = new Vec3(0, view.getVisibleSize().height + offsetY, 0);
		}
  }
}

